package com.xxx.video.channel.activitys;

import android.os.Bundle;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.xxx.video.R;
import com.xxx.video.channel.adapters.AllChannelListAdapter;
import com.xxx.video.channel.presenters.AllChannelPresenter;
import com.xxx.video.channel.presenters.IAllChannelView;
import com.xxx.video.commen.activitys.BaseActivity;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.utils.ListUtils;
import com.xxx.video.commen.utils.StatusBarUtil;
import com.xxx.video.main.beans.HomeTypeListBean;

import java.util.List;

import butterknife.BindView;

public class AllChannelActivity extends BaseActivity<AllChannelPresenter> implements IAllChannelView,
        BaseRecycleViewAdapter.OnItemClickListener<HomeTypeListBean.TypeListBean> {
    @BindView(R.id.rcv_all_channel_list)
    RecyclerView rcvAllChannelList;

    @Override
    public void initToolbarData() {
        super.initToolbarData();
        showActionBar();
        StatusBarUtil.getInstance().setStatusBarTransparent(this, true);
        setIsShowActionbarLine(true);
        setActionBarTitle(R.string.title_all_channel_activity);
    }

    @Override
    protected AllChannelPresenter createPresenter() {
        return new AllChannelPresenter(this, this);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_all_channel;
    }

    @Override
    public void initData(Bundle extras) {
        getPresenter().getTypeList();
    }

    @Override
    public void showRootLayoutStatus(int status) {
        showLayoutStatus(status);
    }

    @Override
    public void initData2View(List<HomeTypeListBean.TypeListBean> typeList) {
        rcvAllChannelList.setLayoutManager(new GridLayoutManager(this, 4));
        AllChannelListAdapter allChannelListAdapter = new AllChannelListAdapter(this);
        rcvAllChannelList.setAdapter(allChannelListAdapter);
        allChannelListAdapter.setOnItemClickListener(this);
        allChannelListAdapter.setData(typeList);
        if (ListUtils.isEmpty(typeList)) {
            showRootLayoutStatus(2);
        } else {
            showRootLayoutStatus(1);
        }
    }

    @Override
    public void startChannelListActivity(String fParentId) {
        Bundle bundle=new Bundle();
        bundle.putString("Id",fParentId);
        intent2Activity(ChannelListActivity.class,bundle);
    }

    @Override
    public void onItemClick(HomeTypeListBean.TypeListBean typeListBean, int position, int type) {
        startChannelListActivity(typeListBean.fId);
    }
}
